package com.wbcs.system.buttons;

import com.wbcs.config.Config;
import com.wbcs.config.component.IComponentConfigBean;
import com.wbcs.config.component.application.report.ReportBean;
import com.wbcs.system.ReportRequest;
import com.wbcs.system.assistant.WbcsAssistant;
import com.wbcs.util.Consts;
import com.wbcs.util.Consts_Private;

public class DataImportButton extends WbcsButton
{
    public DataImportButton(IComponentConfigBean ccbean)
    {
        super(ccbean);
    }

    @Override
	public String getButtonType()
    {
        return Consts.IMPORT_DATA;
    }

    @Override
	public String showButton(ReportRequest rrequest,String dynclickevent)
    {
        return super.showButton(rrequest,getDataImportEvent());
    }
    
    @Override
	public String showButton(ReportRequest rrequest,String dynclickevent,String button)
    {
        return super.showButton(rrequest,getDataImportEvent(),button);
    }

    private String getDataImportEvent()
    {
        String token="?";
        if(Config.showreport_url.indexOf("?")>0) token="&";
        String serverurl=Config.showreport_url+token+"PAGEID="+ccbean.getPageBean().getId()+"&REPORTID="+ccbean.getId()
                +"&ACTIONTYPE=ShowUploadFilePage&FILEUPLOADTYPE="+Consts_Private.FILEUPLOADTYPE_DATAIMPORTREPORT;
        ReportBean rbean=(ReportBean)ccbean;
        String popupparams=WbcsAssistant.getInstance().addDefaultPopupParams(rbean.getDataimportpopupparams(),rbean.getDataimportinitsize(),"300",
                "160",null);
        return "wx_winpage('"+serverurl+"',"+popupparams+");";
    }

}

